Completed
Pull Request — master (#13)
by Justin
07:02
created

not copy instancesꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
var assert = require('chai').assert,
2
    GedcomX = require('../');
3
4
describe('PlaceReference', function(){
5
  
6
  it('Create plain', function(){
7
    var newRef = new GedcomX.PlaceReference(),
8
        ref = GedcomX.PlaceReference();
9
    assert.instanceOf(newRef, GedcomX.PlaceReference, 'An instance of PlaceReference is not returned when calling the constructor with new.');
10
    assert.instanceOf(ref, GedcomX.PlaceReference, 'An instance of PlaceReference is not returned when calling the constructor without new.');
11
  });
12
  
13
  it('Create with JSON', function(){
14
    var ref = GedcomX.PlaceReference({
15
      id: 'ref',
16
      original: 'Miami, Missouri',
17
      description: 'http://place/description'
18
    });
19
    assert.equal(ref.getId(), 'ref');
20
    assert.equal(ref.getOriginal(), 'Miami, Missouri');
21
    assert.equal(ref.getDescription(), 'http://place/description');
22
  });
23
  
24
  it('Build', function(){
25
    var ref = GedcomX.PlaceReference()
26
      .setId('ref')
27
      .setOriginal('Miami, Missouri')
28
      .setDescription('http://place/description');
29
    assert.equal(ref.getId(), 'ref');
30
    assert.equal(ref.getOriginal(), 'Miami, Missouri');
31
    assert.equal(ref.getDescription(), 'http://place/description');
32
  });
33
  
34
  it('toJSON', function(){
35
    var data = {
36
      id: 'ref',
37
      original: 'Miami, Missouri',
38
      description: 'http://place/description'
39
    }, ref = GedcomX.PlaceReference(data);
40
    assert.deepEqual(ref.toJSON(), data);
41
  });
42
  
43
  it('constructor does not copy instances', function(){
44
    var obj1 = GedcomX.PlaceReference();
45
    var obj2 = GedcomX.PlaceReference(obj1);
46
    assert.strictEqual(obj1, obj2);
47
  });
48
  
49
});